package com.ruoyi.system.service.impl.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.CoTestIndustrytype;
import com.ruoyi.system.service.ICoTestIndustrytypeService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 行业类型管理Controller
 * 
 * @author 冬木逢春
 * @date 2022-06-19
 */
@Controller
@RequestMapping("/system/IndustryType")
public class CoTestIndustrytypeController extends BaseController
{
    private String prefix = "system/IndustryType";

    @Autowired
    private ICoTestIndustrytypeService coTestIndustrytypeService;

    @RequiresPermissions("system:IndustryType:view")
    @GetMapping()
    public String IndustryType()
    {
        return prefix + "/IndustryType";
    }

    /**
     * 查询行业类型管理列表
     */
    @RequiresPermissions("system:IndustryType:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(CoTestIndustrytype coTestIndustrytype)
    {
        startPage();
        List<CoTestIndustrytype> list = coTestIndustrytypeService.selectCoTestIndustrytypeList(coTestIndustrytype);
        return getDataTable(list);
    }

    /**
     * 导出行业类型管理列表
     */
    @RequiresPermissions("system:IndustryType:export")
    @Log(title = "行业类型管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(CoTestIndustrytype coTestIndustrytype)
    {
        List<CoTestIndustrytype> list = coTestIndustrytypeService.selectCoTestIndustrytypeList(coTestIndustrytype);
        ExcelUtil<CoTestIndustrytype> util = new ExcelUtil<CoTestIndustrytype>(CoTestIndustrytype.class);
        return util.exportExcel(list, "行业类型管理数据");
    }

    /**
     * 新增行业类型管理
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存行业类型管理
     */
    @RequiresPermissions("system:IndustryType:add")
    @Log(title = "行业类型管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(CoTestIndustrytype coTestIndustrytype)
    {
        return toAjax(coTestIndustrytypeService.insertCoTestIndustrytype(coTestIndustrytype));
    }

    /**
     * 修改行业类型管理
     */
    @RequiresPermissions("system:IndustryType:edit")
    @GetMapping("/edit/{instryId}")
    public String edit(@PathVariable("instryId") Long instryId, ModelMap mmap)
    {
        CoTestIndustrytype coTestIndustrytype = coTestIndustrytypeService.selectCoTestIndustrytypeByInstryId(instryId);
        mmap.put("coTestIndustrytype", coTestIndustrytype);
        return prefix + "/edit";
    }

    /**
     * 修改保存行业类型管理
     */
    @RequiresPermissions("system:IndustryType:edit")
    @Log(title = "行业类型管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(CoTestIndustrytype coTestIndustrytype)
    {
        return toAjax(coTestIndustrytypeService.updateCoTestIndustrytype(coTestIndustrytype));
    }

    /**
     * 删除行业类型管理
     */
    @RequiresPermissions("system:IndustryType:remove")
    @Log(title = "行业类型管理", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(coTestIndustrytypeService.deleteCoTestIndustrytypeByInstryIds(ids));
    }
}
